﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/AdminFunction.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="BitPortal.Admin.Service.ProductCustomer.Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">

    <style type="text/css">
        .x-grid3-cell-inner
        {
            font-family: "segoe ui" ,tahoma, arial, sans-serif;
        }
        
        .x-grid-group-hd div
        {
            font-family: "segoe ui" ,tahoma, arial, sans-serif;
        }
        
        .x-grid3-hd-inner
        {
            font-family: "segoe ui" ,tahoma, arial, sans-serif;
            font-size: 12px;
        }
        
        .x-grid3-body .x-grid3-td-Cost
        {
            background-color: #f1f2f4;
        }
        
        .x-grid3-summary-row .x-grid3-td-Cost
        {
            background-color: #e1e2e4;
        }
    </style>
    <script type="text/javascript">
        var LoadState = function (value) {
            var returnValue = "";
            switch (value) {
                case 1: returnValue = "Chưa duyệt";
                    break;
                case 2: returnValue = "Đã duyệt";
                    break;
                case 3: returnValue = "Đã hoàn thành";
                    break;
            }
            return returnValue;
        }

        var template = '<span style="color:{0};">{1}</span>';

        var LoadColor = function (value) {
            if (value == 1) {
                return String.format(template, "red", LoadState(value));
            } else if (value == 2) {
                return String.format(template, "blue", LoadState(value));
            } else {
                return String.format(template, "black", LoadState(value));

            }



        }
    </script>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="TopBarHolder" runat="server">

</asp:Content>


<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <ext:Store ID="Store1" runat="Server" OnRefreshData="Store1_RefreshData">
        <Proxy>
            <ext:PageProxy/>
        </Proxy>
        <Reader>
            <ext:JsonReader IDProperty="ErrorID">
                <Fields>
                    <ext:RecordField Name="ErrorID" Type="Int" />
                    <ext:RecordField Name="ErrorName" Type="String" />
                    <ext:RecordField Name="DesOfCustomer" Type="String" />
                    <ext:RecordField Name="DateReport" Type="Date" />
                    <ext:RecordField Name="IsApproved" Type="Boolean" />
                    <ext:RecordField Name="StateError" Type="Int" />

                    <ext:RecordField Name="ProductName" Type="String" ServerMapping="ProductCustomer.Product.Name"/>
                    <ext:RecordField Name="ContactName" Type="String" ServerMapping="ProductCustomer.Customer.ContactName" />
                    <ext:RecordField Name="ProductCustomer_DateBuy" Type="Float" ServerMapping="ProductCustomer.DateBuy" />
                    <ext:RecordField Name="ProductCustomer_CountError" Type="Int" ServerMapping="ProductCustomer.CountError" />
                    
                    
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>

    <ext:GridPanel ID="GridPanel1" runat="server" AutoHeight="true" 
        Title="Danh sách lỗi của <%=ProductCustomer_Product_Name %> của khách hàng : <%=ProductCustomer_Customer_ContactName %>"
        StoreID="Store1">
        <ColumnModel runat="Server">
            <Columns>
                <ext:Column  Header="Mã lỗi" DataIndex="ErrorID" Width="50" />
                <ext:Column Header="Tên lỗi" DataIndex="ErrorName" />
                <%--<ext:TemplateColumn Header="Ảnh" Groupable="false" Sortable="false">
                    <Template ID="Template1" runat="server">
                        <Html>
                            <img src="/Handlers/Thumbnail.ashx?p={ThumbImage}&w=80&h=60" width="80" height="60"
                                alt="" />
                        </Html>
                    </Template>
                </ext:TemplateColumn>--%>
                <ext:Column Header="Tên sản phẩm" DataIndex="ProductName"  />
                <ext:Column Header="Khách hàng" DataIndex="ContactName" />
                <ext:DateColumn Header="Ngày mua" DataIndex="ProductCustomer_DateBuy" Format="dd-MM-yyyy" />
                <ext:DateColumn Header="Ngày báo lỗi" DataIndex="DateReport" Format="dd-MM-yyyy" />
                
                <ext:Column Header="Đã duyệt" DataIndex="StateError">
                    
                    <Renderer Fn="LoadColor" />
                </ext:Column>
                
            </Columns>
            
        </ColumnModel>
        <View>
            <ext:GroupingView ID="GroupingView1" runat="server" ForceFit="true" MarkDirty="false"
                ShowGroupName="true" EnableNoGroups="true" HideGroupedColumn="true" ShowGroupsText="Nhóm lại theo cột này" />
        </View>
        <LoadMask ShowMask="true" />
        <Plugins>
            <ext:GridFilters ID="GridFilters1" runat="Server">
                <Filters>
                    <ext:NumericFilter DataIndex="ErrorID" />
                    <ext:StringFilter DataIndex="ErrorName" />
                    <ext:DateFilter DataIndex="DateReport" />
                    <ext:DateFilter DataIndex="ProductCustomer_DateBuy" />
                    <ext:BooleanFilter DataIndex="IsApproved" />

                </Filters>
            </ext:GridFilters>
            <ext:RowExpander runat="Server">
                <Template runat="Server">
                    <Html>
                        <p><b>Mô tả lỗi :</b></p><br />
                        <p>{DesOfCustomer}</p>
                    </Html>
                </Template>
            </ext:RowExpander>
        </Plugins>
        
         <BottomBar>
            <ext:PagingToolbar ID="PagingToolbar1" runat="server" PageSize="10" />
        </BottomBar>
        </ext:GridPanel>
</asp:Content>
